<template>
  <div class="pagebox">
    <div class="l_name bold5 rpx54 col282">欢迎登录</div>

    <div class="l_phone">
      <label class="rpx32 col333">手机号登录</label>
      <input
        @focus="isfocus=true"
        @blur="isfocus=false"
        class="rpx32 col999"
        :class="{app_bor_col:isfocus}"
        confirm-type="done"
        cursor-spacing="10"
        placeholder="请输手机号码"
        placeholder-class="rpx32 col999"
		v-model="inputValue"
      />
    </div>

    <a @click="logoing" class="l_but rpx32 colfff" :class="{app_bg:isphone}">确认登录</a>

    <div class="l_tip">
      <p class="rpx26 col999">工作人员手机号直接登录</p>
      <img src="static/logo.png" class="lt_logo" />
    </div>
	<uni-popup ref="popup"  type="center">{{tip}}</uni-popup>
  </div>
</template>

<script>
import mixins from "@/mixins";
import api from "@/mixins/api";
import {uniPopup} from '@dcloudio/uni-ui'
import '@/uni.scss'
export default {
  // mixins: [mixins],
  components: {uniPopup},
  data() {
    return {
      isfocus: false,
	  isphone: true,
	  inputValue:'',
	  tip:'',
    };
  },
  onBackPress(options) {
    console.log(options);
    if (options.from === "navigateBack") {
      return true;
    }
    // this.back();
    
    return true;
  },
  onLoad(e) {
	  
  },
  methods: {
    logoing() {
		let _that = this;
    //mixins.navigate("index", "reLaunch");
		api.userLogin(_that.inputValue,function(res){
			let data = res.data.data;
			if(data.length != 0){
				//用缓存保存user信息
				uni.setStorage({
					key:'userInfo',
					data:data,
					success:function(){
						mixins.navigate("index", "reLaunch");
					}
				})
			}else{
				//alert(res.data.message)
				 _that.tip = res.data.message
				 _that.$refs.popup.open()
			}
			
		})
    }
  }
};
</script>

<style scoped>
.uni-popup__wrapper-box{
	background: #fff;
}
.l_name {
  height: 210upx;
  line-height: 253upx;
  background: #fff;
  padding-left: 34upx;
  box-shadow: 0upx 8upx 20upx 0upx rgba(112, 2, 9, 0.08);
}
.l_phone {
  margin: 124upx 32upx 0;
}
.l_phone label {
  display: block;
  width: 100%;
  height: 32upx;
  line-height: 1;
}
.l_phone input {
  display: block;
  width: 100%;
  height: 86upx;
  line-height: 86upx;
  margin-top: 38upx;
  border-bottom: 1px solid #c0bbbb;
}
.l_but {
  display: block;
  margin: 120upx auto 0;
  width: 686upx;
  height: 80upx;
  line-height: 80upx;
  text-align: center;
  background: rgba(211, 211, 211, 1);
  border-radius: 40upx;
}
.l_tip {
  position: absolute;
  bottom: 0;
  width: 100%;
}
.l_tip p {
  text-align: center;
}
.lt_logo {
  width: 106upx;
  height: 34upx;
  display: block;
  margin: 40upx auto 46upx;
}
</style>
